<?php

namespace Common\Service;


/** 
 * 专题集合
 * @author Legend. <xcx_legender@qq.com>
 * @param 
 * @return 
 */

Class TopicService extends BaseService
{
	/** 
	title, sort, status, create_time
	videos [ video_ids ]  // 首推的视频IDS 
	1,2,3
	*/
	// 状态
	const STATUS_PEDDING = 0;	// 审核 pedding
	const STATUS_PASS 	 = 1;	// 展示 pass
	const STATUS_DEL  	 = -1;  // 删除 delete

	/**
	*获取栏目列表
	*@param array $filter 筛选条件
	*@param string $field 返回的列
	*@param boolean $keyMap 是否需要设置键值为id标识的值 false|no true|yes
	*@return array
	*@author susy.liang <susy.liang@ilongyuan.com.cn>
	*/
	public function lists($filter=array('status'=>1), $field='id,title', $keyMap=true){
		$listData = $this->where($filter)->field($field)->select();
    	if($keyMap === true){
    		$temp = array();
    		foreach ($listData as $key => $value) {
    			$temp[$value['id']] = $value;
    		}
    		$listData = $temp;
    		unset($temp);
    	}
    	return $listData;
	}

	/**
	*获取栏目下所属的视频
	*@param int $id 栏目标识
	*@return array 视频信息组
	*@author susy.liang <susy.liang@ilongyuan.com.cn>
	*/
	public function getVideos($id){
		$map = array(
			'topics' => $id,
			'status' => 1
		);
		$field = 'id,title';
		$video = D('Common/Video', 'Service')->lists($map, $field);
		return $video;
	}
}